Skip to content

fix: detect unconsumed tokens after parse to catch unbalanced braces (#445) - #475

Merged
hlship merged 1 commit into
masterfrom
hls/20260601-fix-445-unbalanced-braces
Jun 2, 2026
Merged

fix: detect unconsumed tokens after parse to catch unbalanced braces (#445)#475
hlship merged 1 commit into
masterfrom
hls/20260601-fix-445-unbalanced-braces

Conversation

@hlship

@hlship hlship commented Jun 1, 2026

Copy link
Copy Markdown
Member

Summary

  • After ANTLR parses a document, check that the tree's stop-token consumed all non-EOF tokens; throw ParseError if any remain — catches cases where ANTLR's default error recovery silently accepted malformed queries (e.g. missing opening braces)
  • Fix two test queries with a genuine extra } that was previously silently ignored: entities-query in federation_tests and later-fragments-do-not-override-earlier in fragments_tests
  • Add unbalanced-braces regression test covering both cases from issue Unbalanced braces in queries not causing parse-query to fail #445

Closes #445

🤖 Generated with eca

Co-Authored-By: eca-agent git@eca.dev

…445)

ANTLR's default error recovery silently absorbed certain malformed queries
(e.g. missing opening braces) without ever calling the syntaxError listener,
producing a structurally different but syntactically valid parse tree and
leaving trailing tokens unconsumed.

Fix by comparing the document tree's stop-token index against the last
non-EOF token after parsing; throw ParseError if any tokens were skipped.

Also fix two test queries that had a genuine extra `}` that was previously
silently ignored: entities-query in federation_tests and
later-fragments-do-not-override-earlier in fragments_tests.
@hlship hlship self-assigned this Jun 1, 2026
@hlship hlship added this to the 1.3.0 milestone Jun 1, 2026
@hlship
hlship merged commit 5583a02 into master Jun 2, 2026
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

Unbalanced braces in queries not causing parse-query to fail

1 participant